package cn.xiaobai.captcha.handler.dbtype;

import cn.xiaobai.captcha.config.CaptchaProperties;
import cn.xiaobai.captcha.utils.redis.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * mysql 类型处理器
 *
 * @author yangdaji
 * @version 1.0
 * @Description: 各种数据库缓存
 * @date 22-3-7 下午 11:06
 */
@Slf4j
public class RedisAbstractTypeHandler extends AbstractDBAbstractTypeHandler {

    {
        log.info("redis 缓存处理器");
    }

    public RedisAbstractTypeHandler() {
    }

    public RedisAbstractTypeHandler(CaptchaProperties captchaProperties) {
        super(captchaProperties);
    }

    /**
     * redis工具
     */
    @Autowired
    private RedisUtil redisUtil;


    @Override
    public Boolean captchaCache(String key, String value) {
        log.info("使用 redis 缓存");
        return redisUtil.set(key, value, this.getExpire(), this.getTimeUnit());
    }
}
